
#include <iostream>
#include "contacts.pb.h"

int main()
{
    //序列化操作
    contacts::contact conn;
    conn.set_sn(1);
    conn.set_name("小陈");
    conn.set_socre(90.5);
    std::string str = conn.SerializeAsString();

    //反序列化
    contacts::contact stu;
    bool ret = stu.ParseFromString(str);
    if(ret == false)
    {
        //解析失败了
        std::cout << "反序列化失败了" << std::endl;
        return -1;
    }

    std::cout << "stu.sn: " << stu.sn() << std::endl;
    std::cout << "stu.name: " << stu.name() << std::endl; 
    std::cout << "stu.score: " << stu.socre() << std::endl; 

    return 0;
}